﻿namespace Nello
{
    using System;

    public class DateUtil
    {
        public static string GetDate()
        {
            return DateTime.Now.ToShortDateString();
        }

        public static DateTime GetDateTime(string s)
        {
            DateTime dt = DateTime.Now;
            DateTime.TryParse(s, out dt);
            return dt;
        }

        public static string GetNowString()
        {
            return DateTime.Now.ToString("yyyyMMddHHmmss");
        }

        public static string GetString(DateTime dt, string format)
        {
            return dt.ToString(format);
        }

        public static string GetWeek()
        {
            return GetWeek(DateTime.Now);
        }

        public static string GetWeek(DateTime dt)
        {
            switch (dt.DayOfWeek)
            {
                case DayOfWeek.Sunday:
                    return "日";

                case DayOfWeek.Monday:
                    return "一";

                case DayOfWeek.Tuesday:
                    return "二";

                case DayOfWeek.Wednesday:
                    return "三";

                case DayOfWeek.Thursday:
                    return "四";

                case DayOfWeek.Friday:
                    return "五";

                case DayOfWeek.Saturday:
                    return "六";
            }
            return "";
        }
    }
}

